Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize load time and TTFX for non-comparison cases. #137

Merged
merged 8 commits into from
Nov 24, 2024

Conversation

LilithHafner
Copy link
Owner

Changes:

  • Separate _benchmark_1 from benchmark and eliminate keyword arguments
  • Move bench out of _benchmark_1 into its own toplevel function _benchmark_2
  • Inline a constant
  • Update precompile directives

Commits:

  • Remove @nospecialize; no impact on load time, TTFX from 0.24 to 0.19
  • Lots of changes
  • remove unnecessary annotations (no perf change)
  • cleanup precompile NFC
  • refactor, rename, and rearrange. And precompile showing a sample.

Comparison of PR to 1.2.2

julia> f(expr; old=false, show=false) = eval(Meta.parse(read(`julia $(old ? () : "--project") $(show ? "--trace-compile=stderr" : ()) -E $("a = @elapsed using Chairmarks; a,@elapsed @eval $expr")`, String)))
f (generic function with 3 methods)

julia> comp(x) = f(x, old=true) => f(x)
comp (generic function with 1 method)

julia> comp("@b rand evals=1 samples=1")
(0.008544065, 0.038519668) => (0.008942193, 0.033227878)

julia> comp("@b rand hash seconds=.001")
(0.00854119, 0.046308936) => (0.009106361, 0.038525668)

julia> comp("@b rand hash(_) seconds=.001")
(0.008300188, 0.051189014) => (0.008772066, 0.038625961)

julia> comp("@b rand hash evals=1 samples=1")
(0.008669608, 0.041850652) => (0.008984026, 0.037786705)

julia> comp("@b rand hash(_),hash evals=1 samples=1") # This has a major behavior change
(0.008611357, 0.048080741) => (0.008755858, 0.336857771)

Comparison to main (2a3a4a9)

julia> comp("@b rand evals=1 samples=1")
(0.008186062, 0.214978303) => (0.008897401, 0.033137294)

julia> comp("@b rand hash seconds=.001")
(0.008188563, 0.25371418) => (0.008814067, 0.037244033)

julia> comp("@b rand hash(_) seconds=.001")
(0.008199312, 0.254590229) => (0.008687191, 0.038961421)

julia> comp("@b rand hash evals=1 samples=1")
(0.008124103, 0.217730406) => (0.008630858, 0.03827575)

julia> comp("@b rand hash(_),hash evals=1 samples=1")
(0.00789581, 0.225480674) => (0.008701525, 0.332225194)

TTFX for the new comparison usage is still terrible

At this point, TTFX and load time are better than the most recently released version (1.2.2)

```julia-repl
julia> f(expr; old=false, show=false) = eval(Meta.parse(read(`julia $(old ? () : "--project") $(show ? "--trace-compile=stderr" : ()) -E $("a = @Elapsed using Chairmarks; a,@Elapsed @eval $expr")`, String)))
f (generic function with 3 methods)

julia> comp(x) = f(x, old=true) => f(x)
comp (generic function with 1 method)

julia> comp("@b rand evals=1 samples=1")
(0.008823733, 0.038952421) => (0.007316222, 0.033092877)

julia> comp("@b rand hash seconds=.001")
(0.00852394, 0.046460937) => (0.007173346, 0.037048532)

julia> comp("@b rand hash(_) seconds=.001")
(0.00833723, 0.050975096) => (0.007070262, 0.03884667)

julia> comp("@b rand hash evals=1 samples=1")
(0.008731608, 0.042089029) => (0.00729393, 0.03947555)

julia> comp("@b rand hash(_),hash evals=1 samples=1") # This has a major behavior change
(0.009230821, 0.048152574) => (0.007140638, 0.324881723)
```
@LilithHafner
Copy link
Owner Author

RegressionTests reports that load time is up 50% in this PR and TTFX is down 10x. That's consistent with expected TTFX but much worse for expected load time. Worth looking into before releasing.

@LilithHafner LilithHafner merged commit ea0fe66 into main Nov 24, 2024
9 of 17 checks passed
@LilithHafner LilithHafner deleted the lh/simplify-2 branch November 24, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant